<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('绩效打分列表')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="gray-bg">
<div class="modal inmodal fade" id="myModal4" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span
                        aria-hidden="true">&times;</span><span
                        class="sr-only">Close</span>
                </button>
                <h4 class="modal-title">考核日期</h4>
            </div>
            <div class="modal-body">
                <p>
                    年份：<select id="years" name='years' disabled="disabled" class="form-control noselect2">
                    <option value="2020">2020</option>
                    <option value="2021">2021</option>
                    <option value="2022">2022</option>
                </select>
                </p>
                <p>
                    月份:
                    <select id="months" name='months' disabled="disabled" class="form-control noselect2">
                        <option value="1">1</option>
                        <option value="2">2</option>
                        <option value="3">3</option>
                        <option value="4">4</option>
                        <option value="5">5</option>
                        <option value="6">6</option>
                        <option value="7">7</option>
                        <option value="8">8</option>
                        <option value="9">9</option>
                        <option value="10">10</option>
                        <option value="11">11</option>
                        <option value="12">12</option>
                    </select>
                </p>
            </div>
            <div class="modal-footer">
                <button type="button" id="missmodal1" class="btn btn-white" data-dismiss="modal">关闭</button>
                <button type="button" onclick="introduce()" class="btn btn-primary">确认</button>
            </div>
        </div>
    </div>
</div>


<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="dept-form">
                <div class="select-list">
                    <ul>
                        <li>
                            姓名：<input type="text" name="name"/>
                        </li>
                        <li>
                            工号：<input type="text" name="badge"/>
                        </li>
                        <li>
                            部门：
                            <select class="form-control" id="deptId" name="deptId">
                                <option value="">请选择</option>
                                <option th:each="dep:${depList}" th:value="${dep.deptId }"
                                        th:text="${dep.deptName }"></option>
                            </select>
                        </li>
                        <li>
                            岗位：
                            <select class="form-control" id="jobId" name="jobId">
                                <option value="">请选择</option>
                                <option th:each="job:${jobList}" th:value="${job.jobId }"
                                        th:text="${job.jobName }"></option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="validationIntroduction()">
                <i class="fa fa-plus"></i> 选择考核日期
            </a>
            <a class="btn btn-primary" onclick="submitData()">
                </i> 提交
            </a>
            <a class="btn btn-danger" onclick="emptyData()">
                </i> 清空
            </a>
            <a class="btn btn-warning" onclick="refreshPersonnel()"><i
                    class="fa fa-refresh"></i>&nbsp;刷新</a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>

<button type="button" class="btn btn-primary" id="mtkButton" data-toggle="modal" data-target="#myModal4">基本动画</button>


<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>
<script th:inline="javascript">

    var prefix = ctx + "acvScoringManage"

    $(function () {
        $("#mtkButton").attr("style", "display:none;");


        var options = {
            code: "userId",
            uniqueId: "userId",
            url: prefix + "/list",
            createUrl: prefix + "/add/{id}",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove/{id}",
            modalName: "用户",
            columns: [
                {
                    field: 'years',
                    title: '年份'
                },
                {
                    field: 'months',
                    title: '月份'
                },
                {
                    field: 'badge',
                    title: '工号'
                },
                {
                    field: 'examineeName',
                    title: '姓名'
                },
                {
                    field: 'deptName',
                    title: '二级部门'
                },
                {
                    field: 'tertiaryDeptName',
                    title: '三级部门'
                },
                {
                    field: 'jobName',
                    title: '岗位'
                },
                {
                    field: 'scoreTotal',
                    title: '绩效值'
                },
                {
                    field: 'remarksTotal',
                    title: '备注'
                },
                {
                    title: '绩效考核',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-warning btn-xs" href="javascript:void(0)" onclick="toAssessment(\'' + row.examineeId + '\',\'' + row.examineeName + '\',\'' + row.years + '\',\'' + row.months + '\',\'' + row.badge + '\',\'' + row.deptName + '\',\'' + row.jobName + '\',\'' + row.scoringId + '\',\'' + row.remarksTotal + '\',\'' + row.scoreTotal + '\')">进入考核</a> ');
                        return actions.join('');
                    }
                }
            ]
        };
        $.table.init(options);
    });

    function toAssessment(examineeId, name, years, months, badge, deptName, jobName, scoringId, remarksTotal, scoreTotal) {
        //$.modal.openFull("工号:" + badge + "  姓名:" + name + "  部门:" + deptName + "  岗位:" + jobName + "  考核日期:" + years + "年" + months + "月", prefix + "/toScoring?examineeId=" + examineeId);
        window.open(prefix + "/toScoring?examineeId=" + examineeId + "&years=" + years + "&months=" + months + "&scoringId=" + scoringId + "&remarksTotal=" + remarksTotal + "&scoreTotal=" + scoreTotal + "&table=acv_scoring");
    }

    function validationIntroduction() {
        $.ajax({
            type: "post",
            url: prefix + "/validationIntroduction",
            data: {},
            success: function (data) {
                //先验证考核数据是否已经引入
                if (data.code == 1) {
                    $.modal.alertWarning('考核人员已经引入,需提交后引入!');
                } else {
                    var dateArray = data.data.split("-");
                    $("#years").val(dateArray[0]);
                    $("#months").val(parseInt(dateArray[1]));
                    $("#mtkButton").click();
                }
            }
        });
    }

    function introduce() {
        var months = $("#months").val();
        var years = $("#years").val();
        $.ajax({
            type: "post",
            url: prefix + "/introduce",
            data: {
                "months": months,
                "years": years
            },
            success: function (data) {
                //先验证考核数据是否已经引入
                if (data.code == 0) {
                    $("#missmodal1").click();
                    $.modal.alertSuccess('成功!');
                    $.table.search();
                } else {
                    $("#missmodal1").click();
                    $.modal.alertWarning(data.msg);
                }
            }
        });
    }

    function submitData() {
        $.modal.confirm("确认要提交吗?", function () {
            $.ajax({
                type: "post",
                url: prefix + "/submitData",
                data: {},
                success: function (data) {
                    if (data.code == 0) {
                        $.modal.alertSuccess('提交成功!');
                        $.table.search();
                    } else {
                        $.modal.alertWarning(data.msg);
                    }
                }
            });
        });
    }

    function refresh() {
        $("#bootstrap-table").bootstrapTable('refresh');
    }

    function emptyData() {
        $.modal.confirm("确定要清空吗?", function () {
            $.ajax({
                type: "post",
                url: prefix + "/emptyData",
                data: {},
                success: function (data) {
                    if (data.code == 0) {
                        $.modal.alertSuccess('清空成功!');
                        $.table.search();
                    } else {
                        $.modal.alertWarning(data.msg);
                    }
                }
            });
        });
    }

    function refreshPersonnel(){
        $.ajax({
            type: "post",
            url: prefix + "/refreshPersonnel",
            data: {},
            success: function (data) {



            }
        });
    }

</script>
</body>
</html>